package service

import (
	"context"
	"fmt"
	__ "user-srv/basic/proto"
	"user-srv/handler/dao"
)

// server is used to implement helloworld.GreeterServer.
type Server struct {
	__.UnimplementedUserServer
}

// 用户意见添加
func (s *Server) UserOpinionAdd(_ context.Context, in *__.UserOpinionAddReq) (*__.UserOpinionAddResp, error) {
	if in.UserId <= 0 || in.Name == "" || in.Mobile == "" || in.OpinionType == "" || in.OpinionTitle == "" || in.OpinionDetails == "" {
		return nil, fmt.Errorf("参数错误")
	}

	add, err := dao.UserOpinionAdd(in)
	if err != nil {
		return nil, err
	}

	return &__.UserOpinionAddResp{
		Id: int32(add.Id),
	}, nil
}
